﻿function Survey(surveyXmlDocument)
{
    this.xmlDocument = surveyXmlDocument;
}

Survey.prototype.xmlDocument;

Survey.prototype.getId = function()
{
    return this.xmlDocument.selectSingleNode('Survey/id').text;
}

Survey.prototype.setId = function(id)
{
    this.xmlDocument.selectSingleNode('Survey/id').text = id;
}

Survey.prototype.getEnteredOn = function()
{
    return this.xmlDocument.selectSingleNode('Survey/enteredOn').text;
}

Survey.prototype.getFirstName = function()
{
    return this.xmlDocument.selectSingleNode('Survey/firstName').text;
}

Survey.prototype.getLastName = function()
{
    return this.xmlDocument.selectSingleNode('Survey/lastName').text;
}

function CreateSurveByFilePath(surveyPath)
{
    var surveyFile = fileSystemObject.GetFile(surveyPath);  
    return CreateSurveByFile(surveyFile);
}

function CreateSurveByFile(surveyFile)
{
    var surveyStream = fileSystemObject.OpenTextFile(surveyFile,1,false,0);
    var surveyContent = surveyStream.ReadAll();
    surveyStream.Close();
    
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;
    xmlDoc.loadXML(surveyContent);
    return new Survey(xmlDoc);
}